//
//  BaseTableViewController.swift
//  weibo
//
//  Created by apple on 16/2/20.
//  Copyright © 2016年 apple. All rights reserved.
//

import UIKit
//遵守代理
class BaseTableViewController: UITableViewController ,VisitorLoginViewDelagate{

    //标记用户是否登录
    var userlogin = AccountViewModel.sharedAccountViewModel.userLogin
    
    //设置访客视图
    var visitorLoginView: VisitorLoginView?
    
    override func loadView() {
        if userlogin {
        //登录   加载tableView
            super.loadView()
        }else{
        //未登录  显示访客视图
            visitorLoginView = VisitorLoginView()
            
            //指定代理
            visitorLoginView?.visitorLoginViewDelagate = self
            
            view = visitorLoginView
            
            //设置导航条
            navigationItem.leftBarButtonItem = UIBarButtonItem(title: "登录", style: .Plain, target: self, action: "userWillLogin")
            navigationItem.rightBarButtonItem = UIBarButtonItem(title: "注册", style: .Plain, target: self, action: "userWithRegister")
            
        
        }
    }
    
//    实现代理方法
    func userWillLogin() {
        let oauth = OAuthViewController()
        let nav = UINavigationController(rootViewController: oauth)
        presentViewController(nav, animated: true, completion: nil)
    }
    
    func userWithRegister() {
        
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()

    }



}
